package com.mark.java.service;

import com.mark.java.dao.UserDAO;
import com.mark.java.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * Created by mark on 4/24/15.
 *
 * 这个annotation为Transactional，就是指明每个方法是一个事务。
 */
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDao;

    public int saveUsers(User us) {
           return userDao.save(us);
    }

    public List<User> getAllUsernames() {
        return userDao.findAll();
    }

    public User findUserById(String phone) {
        return   userDao.findUserById(phone);
    }
}
